/**  
* @Title: TopBaiduBdbHelp.java
* @Package org.zsen.crawler
* @Description TODO
* @author ZhangSen
* @date 2015年11月1日 下午8:40:26
* @version 
*/ 
package org.zsen.crawler;

import java.io.UnsupportedEncodingException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sleepycat.je.Cursor;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;

/**
* @ClassName: TopBaiduBdbHelp
* @Description: 
* @author ZhangSen
* @date 2015年11月1日 下午8:40:26
*
*/
public class BaiduBdbHelp extends BbdHelper{

	/**
	* Description: TODO
	* @param path
	*/ 
	public static final Logger LOG = LoggerFactory.getLogger(BaiduBdbHelp.class);
	public BaiduBdbHelp(String path) {
		super(path);
		// TODO Auto-generated constructor stub
	}

	/**
	* @Description: TODO
	* @param cursor
	* @author ZhangSen
	* @date 2015年11月1日 下午8:40:57      
	*/ 
	@Override
	void read(Cursor cursor) {
		DatabaseEntry key=new DatabaseEntry();
		DatabaseEntry value=new DatabaseEntry();
		String skey = null,svalue = null;
		 while(cursor.getNext(key, value, LockMode.DEFAULT)==OperationStatus.SUCCESS){
			 		
	            	try {
						svalue=new String(value.getData(),"utf-8");
						skey=new String(key.getData(),"utf-8"); 
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}
					LOG.warn("[key : "+skey+" value: "+svalue+"]");
		 }
		
	}

	/** 
	* @Description: TODO
	* @param db
	* @author ZhangSen
	* @date 2015年11月1日 下午9:08:32      
	*/ 
	@Override
	void write(Database db) {
		// TODO Auto-generated method stub
		
	}
	public static void main(String[] args) {
		BaiduBdbHelp dbh=new BaiduBdbHelp("Baidu");
		dbh.setRead(true);
		dbh.execute("实时热点");
	}

}
